﻿using System;
using InterfaceLiftLib.Service.Implementations;
using InterfaceLiftLib.Service.Interfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace InterfaceLiftTests
{
    [TestClass]
    public class HttpWebRequestBuilderShould
    {
        private IHttpWebRequestBuilder m_webRequestBuilder = null;

        [TestInitialize]
        public void TestInit()
        {
            m_webRequestBuilder = new MashapeHttpWebRequestBuilder(new CamelCaseUrlBuilder(), "YOUR MASHAPE API KEY HERE");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowIfNoMashapeApiKeySpecified()
        {
            m_webRequestBuilder = new MashapeHttpWebRequestBuilder(new CamelCaseUrlBuilder(), null);            
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ThrowIfMethodInfoIsNull()
        {
            m_webRequestBuilder.BuildRequest(null, null, null);
        }

        [TestMethod]
        public void CreateValidRequest()
        {            
            var methodInfo = this.GetType().GetMethod("FakeMethodForTest");
            var request = m_webRequestBuilder.BuildRequest(methodInfo, 1, "myName", "555 123");
            Assert.IsNotNull(request, "Request is null");            
        }

        public void FakeMethodForTest(int id, string name, string phoneNumber) { }
    }
}
